<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<jsp:directive.page import="com.toncen.samepms.demo.domain.DemoChild"/>
<jsp:directive.page import="com.sky.dataimport.parser.DynamicRowExcelDataParser"/>
<jsp:directive.page import="com.sky.dataimport.parser.DynamicCellExcelDataParser"/>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="g" uri="/fishergrid-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title><s:property value="operate"/>主表示例</title>
	<%@include file="/share/header.jsp"%>
	<s:head/>	
	<g:header theme="${sessionScope.skinCon.gridSkin}"/>	
  </head>
  <body >
	<script type="text/javascript">
		//新增
		function onDoAdd(name,g){
			var options={
				title:'【新增从表示例】',
				url:'<s:url action='new' namespace='/demo/child'  includeParams="all" escapeAmp="false"/>',
				source : window,
				buttons:[top.MyWindow.OkClose,top.MyWindow.OkAdd,top.MyWindow.Cancel],
				multiplewidth:1,
				multipleheight:0.5,
				tipstitle:'',
				tipscontent:''
			};
			top.MyWindow.open(options);
		}
		//Excel批量导入
		function onDoExcelImport(name,g){
			var options={
				title:'【Excel批量导入】',
				url:'<s:url action='importExcel' namespace='/office'  includeParams="all" escapeAmp="false"/>&manyPropertyName=<s:property value="manyPropertyName"/>&onePropertyName=<s:property value="onePropertyName"/>&modelClassName=<%=DemoChild.class.getName()%>&modelClassName=<%=DemoChild.class.getName()%>&parserClassName=<%=DynamicRowExcelDataParser.class.getName()%>&parserClassName=<%=DynamicCellExcelDataParser.class.getName()%>&templatePath=/template/excel/DemoChild.xls',
				source : window,
				buttons:[top.MyWindow.Import,top.MyWindow.Cancel],
				multiplewidth:1,
				multipleheight:0.8,
				tipstitle:'',
				tipscontent:''
			};
			top.MyWindow.open(options);
		}		
		//修改		
		function onDoOperateRenderer(tdDiv,pid){
			var operate="修改";
		<s:if  test="readonly||right.modifyRight!=1">
			operate="查看";
		</s:if>
			var options={
				title:'【'+operate+'从表示例】',
				url:'<s:url action="%{(readonly||right.modifyRight!=1)?'view':'edit'}" namespace='/demo/child'  includeParams="all" escapeAmp="false"/>&domain.id='+pid,
				source : window,
			<s:if  test="readonly||right.modifyRight!=1">
				buttons:[top.MyWindow.Close],
		  	</s:if>
	  		<s:else>
	  			buttons:[top.MyWindow.OkClose,top.MyWindow.OkAdd,top.MyWindow.Cancel],
	  		</s:else>				
				multiplewidth:1,
				multipleheight:0.6,
				tipstitle:'',
				tipscontent:''
			};
			var edtihtml='<a href="javascript:void(0);" title="'+operate+'">'+operate+'</a>';
			$(tdDiv).html("");//去除原有的内容
			$(tdDiv).append($(edtihtml).click(function(){//添加链接
											top.MyWindow.open(options);
										})
							);
		}	
		//查看		
		function onDoNameRenderer(tdDiv,pid){
			var options={
				title:'【查看从表示例】',
				url:'<s:url action="view" namespace='/demo/child'  includeParams="all" escapeAmp="false"/>&domain.id='+pid,
				source : window,
				buttons:[top.MyWindow.Close],
				multiplewidth:1,
				multipleheight:0.5,
				tipstitle:'',
				tipscontent:''
			};			
			var viewhtml='<a href="javascript:void(0);" title="查看【'+$(tdDiv).html()+'】详细信息">'+$(tdDiv).html()+'</a>';
			$(tdDiv).html("");//去除原有的内容
			$(tdDiv).append($(viewhtml).click(function(){//添加链接
											top.MyWindow.open(options);
										})
							);				
		}		
		//删除
		function onDoDelete(name,grid){
			onDoAjax({url:'<s:url action='deletes' namespace='/demo/child'  includeParams="all" escapeAmp="false"></s:url>'});
		}	
		//启用
		function onDoEnable(name,grid){
			onDoAjax({url:'<s:url action='changes' namespace='/demo/child'  includeParams="all" escapeAmp="false"></s:url>&domain.state=1',tip:'启用'});
		}
		//停用
		function onDoUnEnable(name,grid){
			onDoAjax({url:'<s:url action='changes' namespace='/demo/child'  includeParams="all" escapeAmp="false"></s:url>&domain.state=2',tip:'停用'});
		}
		//复制
		function onDoCopy(name,grid){
			onDoAjax({url:'<s:url action='copys' namespace='/demo/child'  includeParams="all" escapeAmp="false"></s:url>&copyName=name',tip:'复制'});
		}
		//批量保存
		function onDoSaves(name,grid){
			fisherSaves({url:'<s:url action='saves' namespace='/demo/child' includeParams="all" escapeAmp="false"></s:url>'});
		}												
	</script>  
  	<s:actionerror/>
  	<g:grid title="从表示例列表" name="/demo/demochild.fisher.xml" rp="5" queryBreak="2" url="/fisher/jsp/memory.jsp?actionName=${requestScope.actionName}&attributeName=${requestScope.attributeName}&manyPropertyName=${requestScope.manyPropertyName}&onePropertyName=${requestScope.onePropertyName}">
  		<s:if  test="!readonly">
	  		<g:select/>
	  		<s:if test="right.size==0||right.addRight==1">
	  		<g:separator/>  
	  		<g:button name="新增" styleClass="fisherAdd" onclick="onDoAdd"/>
	  		</s:if>
	  		<g:button name="保存" styleClass="fisherSave" onclick="onDoSaves"/>  		
	  		<g:separator/> 	  		
	  		<s:if test="right.size==0||right.importExcelRight==1">
	  		<g:separator/>  
			<g:button name="Excel批量导入" styleClass="fisherDownload" onclick="onDoExcelImport"/>  
			</s:if>		
			<s:if test="right.size==0||right.enableRight==1">
	  		<g:separator/> 
	  		<g:button name="启用" styleClass="fisherCheck" onclick="onDoEnable"/>
	  		</s:if>
	  		<s:if test="right.size==0||right.unEnableRight==1">
	  		<g:separator/>  
	  		<g:button name="停用" styleClass="fisherUncheck" onclick="onDoUnEnable"/>
	  		</s:if>
	  		<s:if test="right.size==0||right.copyRight==1">
	  		<g:separator/>  
	  		<g:button name="复制" styleClass="fisherCopy" onclick="onDoCopy"/>
	  		</s:if>
	  		<s:if test="right.size==0||right.delRight==1">
	  		<g:separator/>   		  		 
	  		<g:button name="删除" styleClass="fisherDelete" onclick="onDoDelete"/>
	  		</s:if>
	  		<g:separator/>
	  	</s:if>
	  		<g:query/>	 
	  		<g:separator/> 	
  	</g:grid>
  </body>
</html>
